<?php
$this->breadcrumbs = array(
    '广告位' => array('site/index'),
    '管理',
);
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/js/colorbox/jquery.colorbox-min.js');
Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl . '/js/colorbox/colorbox.css');
Yii::app()->clientScript->registerScript('search', " 
$('form.search-form').submit(function(){ 
    $.fn.yiiGridView.update('web-adsmanage-sort-grid', { 
        data: $(this).serialize() 
    }); 
    return false; 
}); 

$('#web-adsmanage-sort-grid tbody > tr > td.td_important >a ').click(function(){
    var ads_start = 0;
    var ref_type = $(this).attr('ref');
    $('a[ref='+ref_type+']').attr('class','set-important');
    if(this.className=='set-important'){
        this.className='important';
        ads_start = 1;
    }else{
        this.className='set-important';
        ads_start = 0;
    }
    $.ajax({
        url:this.href,
        data:{ads_start:ads_start}
    });
    return false;
});


$('#delete-button').click(function(){
            var selects = $.fn.yiiGridView.getSelection('web-adsmanage-sort-grid');
            if(selects==''){
            alert('请选中记录进行操作！');
            }else{
            if(window.confirm('此删除会将本广告位下关联的广告全部删除！您确定要删除吗?')){
            $.fn.yiiGridView.update('web-adsmanage-sort-grid', {
            type:'POST',
            url:'" . $this->rewriteCreateUrl('delete') . "',
            data:{id:selects},
            success:function(data) {
            $.fn.yiiGridView.update('web-adsmanage-sort-grid');
            //afterDelete(th,true,data);
            },
            error:function() {
            //afterDelete(th,false);
            }
});
return false;
}
}
});
");
?>
<div class="box corners shadow">
    <div class="box-header">
        <h2>广告位管理</h2>
        <div class="box-header-ctrls">	
            <a href="javascript:void(null);
               " title="" class="close"><!-- --></a>
        </div>
    </div>

    <div style="display:none">
        <div id="inline_content" class="inbox-sf" style="padding-top:20px">
            <input type="text" id="goldinput"class="input-1" style="width:400px;" value="">
            <input type="submit" name="" onclick="$('#goldinput').select();" value="复制代码" class="inbox-sf-search-btn" style="padding-top: 2px;">
        </div>
    </div>
    <div class="box-content" id="contacts-1a">
        <div class="inbox-sf">
            <form class="search-form">
                <?php echo CHtml::textField('WebAdsmanageSort[ads_name]', '', array('class' => 'input-1 tip', 'title' => '输入分类名称查询')); ?>
                <?php echo CHtml::dropDownList('WebAdsmanageSort[ads_webset]', '', array('' => '') + Subsite::model()->getSiteSelect(), array('class' => 'tip', 'title' => '选择站点查询')); ?> 
                <?php echo CHtml::dropDownList('WebAdsmanageSort[ads_start]', '', array('' => '') + Infosort::model()->sort_state_array, array('class' => 'tip', 'title' => '选择状态查询')); ?> 

                <input type="submit" name="" value="查询" class="inbox-sf-search-btn" />
            </form>
            <a class="button black fr tip" id="delete-button" href="javascript:void(null);"  title="选中数据进行删除！">
                <span>批量删除</span>
            </a>
            <a class = "button black fr" href = "<?php echo $this->rewriteCreateUrl('create') ?>">
                <span>添加广告位</span>
            </a>

        </div>
        <?php
        $this->widget('zii.widgets.grid.CGridView', array(
            'id' => 'web-adsmanage-sort-grid',
            'dataProvider' => $model->search(),
            'cssFile' => '',
            'htmlOptions' => array('class' => ''),
            'template' => '{summary}{items}{pager}',
            'itemsCssClass' => 'tablebox',
            'pager' => array(//通过pager设置样式   默认为CLinkPager
                'prevPageLabel' => '<<',
                'firstPageLabel' => '首页', //first,last 在默认样式中为{display:none}及不显示，通过样式{display:inline}即可
                'nextPageLabel' => '>>',
                'lastPageLabel' => '末页',
                'header' => '',
                'htmlOptions' => array('class' => 'box-nav')
            ),
            'selectableRows' => 2,
            'columns' => array(
                array(
                    'class' => 'CCheckBoxColumn',
                    'header' => '全选',
                    'value' => '$data->id',
                    'id' => 'delete',
                    'htmlOptions' => array('style' => 'width:20px')
                ),
                'id',
                array(
                    'name' => 'ads_webset',
                    'value' => 'Subsite::model()->getNameById($data->ads_webset, "domain")',
                ),
                'ads_name',
                array(
                    'name' => 'ads_start',
                    'type' => 'raw',
                    'htmlOptions' => array(
                        'class' => 'td_important',
                    ),
                    //      'value' => $model->state == 1 ? '激活' : '未激活',
                    'value' => 'WebAdsmanageSort::model()->getCustomerState($data)',
                ),
                array(
                    'name' => 'ads_type',
                    'value' => 'WebAdsmanageSort::model()->ads_type_array[$data->ads_type]',
                ),
                'ads_height',
                'ads_width',
                'start_time',
                'end_time',
                array(
                    'type' => 'raw',
                    'htmlOptions' => array('style' => 'width:230px'),
                    'value' => 'WebAdsmanageSort::model()->getColumnOptions($data)',
                ),
            ),
        ));
        ?>         
    </div><!-- END ".box-content" --> 
</div>